function debounce(callback, time) {
  let ptr = '';
  return function(...args) {
    if(ptr) {
      clearTimeout(ptr);
    }
    ptr = setTimeout(function() {
      callback.apply(null, args);
      ptr = null;
    }, time)
  }
}
let fun = debounce(function() {
  console.log('ppp')
}, 200);

setInterval(fun, 300);